<?php

class Contact_Form_Contatto extends Zend_Form
{

    public function init()
    {
        // Name element
        $name = $this->createElement('text', 'name');
        // Name element options
        $name->setLabel('Nome:');
        $name->setRequired(TRUE);
        $name->setAttrib('size', 40);
        $name->addDecorators(array(
            'ViewHelper',
            array('Errors', array(
                                'class' =>'error list-style-type-none'
            )),
        ));
        // Add name element to the form
        $this->addElement($name);
        
        //**********************************************************************
        
        // Email element
        $email = $this->createElement('text', 'email');
        // Email element options
        $email->setLabel('Email:');
        $email->setRequired(TRUE);
        $email->setAttrib('size', 40);
        $email->addValidator('EmailAddress');
        $email->addErrorMessage('Inserisci un indirizzo email valido, per favore.');
        $email->addDecorators(array(
            'ViewHelper',
            array('Errors', array(
                                'class' =>'error list-style-type-none'
            )),
        ));
        // Add eamil element to the form
        $this->addElement($email);
        
        //**********************************************************************
        
        // Subject element
        $subject = $this->createElement('text', 'subject');
        // Subject element options
        $subject->setLabel('Oggetto:');
        $subject->setRequired(TRUE);
        $subject->setAttrib('size', 60);
        $subject->addDecorators(array(
            'ViewHelper',
            array('Errors', array(
                                'class' =>'error list-style-type-none'
            )),
        ));
        // Add subject element to the form
        $this->addElement($subject);
        
        //**********************************************************************
       
        // Message element
        $message = $this->createElement('textarea', 'message');
        // Name element options
        $message->setLabel('Messaggio:');
        $message->setRequired(TRUE);
        $message->setAttrib('cols', 50);
        $message->setAttrib('rows', 12);
        $message->addDecorators(array(
            'ViewHelper',
            array('Errors', array(
                                'class' =>'error list-style-type-none'
            )),
        ));
        // Add name element to the form
        $this->addElement($message);
        
        //**********************************************************************
        
        //Configure the CAPTCHA service
        // Ricorda di cambiare il diminio per il sito in produzione
        $privateKey = '6LfJgdMSAAAAAO1nfSnJbGwJp83hKXQlUqHa43lJ';
        $publicKey = '6LfJgdMSAAAAAJNpAO65ZOavslXPf4AI9IcRr1Ji';
        $recaptcha = new Zend_Service_ReCaptcha($publicKey, $privateKey);
        
        //Create CAPTCHA control
        $captcha = new Zend_Form_Element_Captcha('captcha', array(
            'captcha' => 'ReCaptcha',
            'captchaOptions' => array('captcha' => 'ReCaptcha',
                                      'service' => $recaptcha,
                                      'lang' =>'it',
                )
        ));
        $captcha->addErrorMessage('Testo di conferma errato.');
        $captcha->addDecorators(array(
            array('Errors', array(
                                'class' =>'error list-style-type-none'
            ))
        ));
        
        // Add captha to the form
        $this->addElement($captcha);
        
        //**********************************************************************
        
        //Submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Invia!');
        $submit->setAttrib('class', 'push-1');
        $this->addElement($submit);
    }


}

